home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 March / SGI IRIX Patches 1995 Mar.iso / 5.2_patches / patchSG0000226 / patchSG0000226.idb / usr / include / sys / pda.h.z / pda.h
C/C++ Source or Header  |  1995-03-10  |  13KB  |  402 lines

  1. /**************************************************************************
  2.  *                                      *
  3.  *          Copyright (C) 1986, Silicon Graphics, Inc.          *
  4.  *                                      *
  5.  *  These coded instructions, statements, and computer programs  contain  *
  6.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  7.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  8.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  9.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  10.  *                                      *
  11.  **************************************************************************/
  12. #ifndef __SYS_PDA_H__
  13. #define __SYS_PDA_H__
  14.  
  15. #ident "$Revision: 3.98 $"
  16.  
  17. /*
  18.  * sysmp(MP_STAT) structure
  19.  */
  20. struct pda_stat {
  21.     int        p_cpuid;    /* processor ID */
  22.     int        p_flags;    /* various flags */
  23. };
  24.  
  25. /* values for p_flags */
  26. #define PDAF_MASTER    0x0001
  27. #define PDAF_CLOCK    0x0002
  28. #define PDAF_ENABLED    0x0004        /* processor allowed to sched procs */
  29. #define    PDAF_FASTCLOCK    0x0008        /* processor handles fastimer */
  30. #define PDAF_ISOLATED    0x0010        /* processor is isolated */
  31. #define PDAF_BROADCAST_OFF    0x0020    /* broadcast intr is not received */
  32. #define PDAF_NONPREEMPTIVE    0x0040    /* processor is not preemptive */
  33.  
  34. #ifdef _KERNEL
  35. #include <sys/immu.h>
  36. #include <sys/timers.h>
  37. #include <sys/runq_private.h>
  38.  
  39. #ifdef EVEREST
  40. #include <sys/EVEREST/everest.h>
  41. #endif
  42.  
  43. /*
  44.  * The private data area for each processor
  45.  * Always appears at the same virtual address in each processor
  46.  * It is one page (4K), and we use the bottom 1024 bytes as a
  47.  * boot/idle stack.
  48.  */
  49.  
  50. /*
  51.  * the pda itself
  52.  */
  53. typedef struct pda_s {
  54.     union {
  55.         int    dbg[4];
  56.         struct {
  57.         inst_t    *exceptnorm;    /* general exception handler */
  58.         int    filler[3];
  59.         } common;
  60.     } db;
  61.     int        p_cpuid;    /* my processor ID */
  62.     cpumask_t    p_cpumask;    /* my processor ID mask */
  63.     int        p_runrun;    /* switch on return to user */
  64.     uint        p_kstackflag;    /* kernel stack flag */
  65.     k_machreg_t    *p_intstack;    /* base of interrupt stack */
  66.     k_machreg_t    *p_intlastframe;/* last frame on interrupt stack */
  67.     k_machreg_t    *p_bootstack;    /* base of boot/idle stack */
  68.     k_machreg_t    *p_bootlastframe;/* last frame on boot/idle stack */
  69.     int        p_nested_intr;    /* in nested interrupt */
  70.     k_machreg_t    p_atsave;
  71.     k_machreg_t    p_t0save;
  72.  
  73.     /* fields for segment table manipulation */
  74.     k_machreg_t    p_k1save;    /* save k1 */
  75. #if OLD_SEGTBL
  76.     caddr_t        *p_gsegtbl;    /* global segment table */
  77. #endif
  78.  
  79.     caddr_t        p_idlstkdepth;    /* store sp on interrupt on idl stack */
  80.     int        p_flags;    /* various flags */
  81.     struct proc    *p_curproc;    /* current process */
  82.     int         p_curpri;    /* current priority */
  83.     struct proc    *p_lastproc;    /* last process */
  84.     int        p_ignore;    /* last process ignored by parent */
  85.     int        p_cputype_word;    /* cpu rev */
  86.     int        p_fputype_word;    /* fpu rev */
  87.     int        p_nofault;    /* processor nofaults */
  88.     caddr_t        p_kvfault;    /* processor kernel fault history */
  89.     caddr_t        p_clrkvflt[8];
  90.     unsigned int    p_hand;        /* a pseodo-random value */
  91.     struct tlbinfo    *p_tlbinfo;    /* tlb management info */
  92.     struct proc    *p_fpowner;    /* process owning fpu */
  93.     int        p_switching;    /* processor in swtch */
  94.     int        p_idleflag;    /* processor idle */
  95.     int        p_idletkn;    /* reasons of processor idle */
  96.     int        p_lticks;    /* ticks left in time slice */
  97.     int        p_vmeipl;    /* non-kmode VME interrupt level */
  98.     int        p_curlock;    /* address of lock cpu is going after */
  99.     int        p_lastlock;    /* addr of last lock locked */
  100.     inst_t        *p_curlockcpc;    /* calling pc */
  101.     inst_t        *p_cursemcpc;    /* pc invoking last semaphore op */
  102.     int        p_savespl;    /* previous spl of spsemahi */
  103.     int        p_gfx_waitc;    /* waiting for gfx context swtch */
  104.     int        p_gfx_waitf;    /* waiting for gfx fifo */
  105.     unsigned    *prfptr;    /* ptr to profiler count table */
  106.     struct ksa    *ksaptr;    /* ptr to kernel system activities buf*/
  107.     struct action_s *p_todolist;    /* list of actions to do for others */
  108.     struct action_s *p_lasttodo;    /* last actions to do for others */
  109.     int        p_triggersave;  /* 3-way trigger state (IP5 only) */
  110.     /*
  111.      * Local LED pattern maintainence.
  112.      */
  113.     unsigned     p_led_counter;
  114.     unsigned    p_led_value;
  115.  
  116.     unsigned    p_dbgcntdown;    /* ticks between debugger checks */
  117.     /*
  118.      * Special modifications lock.  Used to allow other processors
  119.      * to change p_flags or p_vmeipl (to distribute functionality).
  120.      */
  121.     lock_t        p_special;
  122.     int        p_cputype;    /* 0 for IP7, 1 for IP5 (MP only) */
  123.  
  124.     /* for handling timein */
  125.     int        p_timein;    /* set by timepoke */
  126.     int        p_ftimein;    /* set by fast_timnepoke */
  127.  
  128.     int        fclock_freq;    /* freq of profiling clock */
  129.     int        p_schedflags;    /* scheduling flags mod by owner only */
  130.     struct shaddr_s    *p_dispatch;    /* Share group to dispatch member of */
  131.     uint        p_acvec;    /* opcode vector for cpuvaction() */
  132.     uint        p_delayacvec;    /* opcode vector for delay action */
  133.     uint        p_upglo;    /* tlblo entry for upage */
  134.     uint        p_ukstklo;    /* tlblo entry for ukstk */
  135.     uint        p_pdalo;    /* tlblo entry for pda page */
  136.     uint        p_utlbmisses;    /* count utlbmisses */
  137.     uint        p_sv1lo;    /* tlblo entry for save of slot 1 */
  138.     uint        p_sv1lo_1;    /* r4k: 2nd tlblo entry for slot 1 */
  139.     uint        p_sv1hi;    /* tlbhi entry for save of slot 1 */
  140.     uint        p_sv2lo;    /* tlblo entry for save of slot 2 */
  141.     uint        p_sv2lo_1;    /* r4k: 2nd tlblo entry for slot 2 */
  142.     uint        p_sv2hi;    /* tlbhi entry for save of slot 2 */
  143.  
  144.     /* scheduling values for the processor */
  145. #ifdef RQ_EMBEDDED
  146.     runqpda_t    p_runqpda;
  147. #else
  148.     struct runqpda    *p_runqpda;
  149. #endif
  150.  
  151.     /* data needed to handle IO intr */
  152.     uint        *ioep[2];    /* exception frame ptr */
  153.     int        iopend[2];    /* accumulated io pending bits */
  154.     int        preempted_iolv[2]; /* io levels being preempted */
  155.  
  156.     /* delay calibration info */
  157.     int         decinsperloop;  /* deci-nanoseconds per 10 DELAY loop */    
  158.  
  159.     /* floating point interrupt data */
  160.     inst_t        p_epcinst;    /* instruction at epc */
  161.     inst_t        p_bdinst;    /* instruction in bd slot */
  162.  
  163.     /* special utlbmiss handlers */
  164.     int        p_utlbmissswtch; /* index of utlbmiss handler */
  165.     int           *p_utlbmisshndlr; /* address of utlbmiss handler */
  166.  
  167.     /* special reserved virtual address lists for use in page_copy 
  168.      * and page_zero.  Should only be used by those routines.
  169.      */
  170.     char        p_pcopy_inuse[2];
  171.     int        *p_pcopy_pagelist[2];
  172.     /* special reserved virtual address for use in cache operations */
  173.     int        *p_cacheop_pages;
  174. #if !STAT_TIME
  175.     int        p_timerstate;    /* for locore */
  176.         timer_t         *p_oldtimer; /* previously active timer, for intr */
  177.         timer_t         *p_activetimer; /* points to currently active timer */
  178. #endif /* !STAT_TIME */
  179. #if JUMP_WAR
  180. #define JUMP_WAR_SETS    3
  181. #define NWIREDJUMP    3
  182.     int         p_jump_war_pte[JUMP_WAR_SETS][2*NWIREDJUMP];
  183.     uint         p_jump_war_stats[NWIREDJUMP*2];
  184.     uint         p_jump_war_set_stats[JUMP_WAR_SETS];
  185.     uint         p_jump_war_stolen;
  186.     uint         p_jump_war_set;
  187.     uint         p_max_jump_war_wired;
  188. #endif /* JUMP_WAR */
  189.     uint        p_rtclock_rate;        /* R4k cycles/lbolt tick */
  190.     char        *p_vcelog;        /* log of VCE exceptions (DEBUG) */
  191.     int        p_vcelog_offset;    /* offset into log of last entry*/
  192.     int        p_vcecount;        /* count of VCE exceptions */
  193.     int        p_prf_enabled;        /* 1 == kernel profiling on */
  194. #if EVEREST
  195.     evreg_t        cmp_RTC_OBSOLETE;     /* when comparator was last set */
  196.     evreg_t        last_sched_intr_RTC;
  197.     long long    counter_intr_over_sum;    /* sum of cycles over norm */
  198.     uint        counter_intr_over_count;/* number of events */
  199.     uint        counter_intr_over_max;    /* max cycles over norm */
  200. #endif /* EVEREST */
  201. #if EXTUSIZE == 1
  202.     pde_t        p_stackext;    /* PTE for kernel stack extension */
  203.     pde_t        p_bp_stackext;    /* PTE for backup kernel stack ext. */
  204.     int        p_mapstackext;    /* Flag to indicate stk ext needs to be mapped */
  205. #endif
  206. } pda_t;
  207.  
  208. /*    UTLBMISS_* defines the bitmask of utlbmiss handlers
  209.  *    ``installed'' in each pda.
  210.  */
  211. #define UTLBMISS_STD    0
  212. #define UTLBMISS_COUNT    1
  213. #define UTLBMISS_DEFER    2
  214.  
  215. #define NUTLBMISS_HNDLRS    4    /* number of utlbmiss handlers */
  216.  
  217. struct utlbmiss_swtch {
  218.     int    *u_start;
  219.     int    *u_end;
  220. };
  221. extern struct utlbmiss_swtch utlbmiss_swtch[];
  222.  
  223. #define    common_excnorm        db.common.exceptnorm
  224.  
  225. #if !STAT_TIME
  226. /* value for p_timerstate */
  227. #define PDA_SAVE_OLDTIMER    0x1
  228. #define PDA_INTTIMER_SWTCH    0x2
  229. #define PDA_SYSTIMER_SWTCH    0x4
  230. #endif
  231.  
  232. /* ``run-anywhere'' value for p_mustrun */
  233. #define PDA_RUNANYWHERE        ((cpuid_t)-1)
  234.  
  235. /* values for kstackflag */
  236. #define PDA_CURUSRSTK        0 /* currently running on user stack */
  237. #define PDA_CURKERSTK        1 /* currently running on kernel user stack */
  238. #define PDA_CURINTSTK        2 /* currently running on interrupt stack */
  239. #define PDA_CURIDLSTK        3 /* currently running on idle stack */
  240.  
  241. /* values for p_schedflags */
  242. #define    PDAS_KICKIDLE    0x0001    /* do a kickidle later */
  243.  
  244. typedef struct {
  245.     int    CpuId;
  246.     pda_t    *pda;
  247. } pdaindr_t;
  248.  
  249. extern pdaindr_t    pdaindr[];
  250. extern int        numcpus;    /* count of configured cpus */
  251. extern cpumask_t    maskcpus;    /* mask of configured cpus */
  252. extern int        maxcpus;    /* max configured cpus */
  253. extern pda_t        *masterpda;    /* master processor's pda */
  254. #ifdef MP
  255. extern cpuid_t        getcpuid(void);
  256. #else
  257. #define getcpuid()    0
  258. #endif
  259. extern int        sendintr(cpuid_t, unchar);
  260.  
  261. #define PDASZ        1        /* # pages of pda */
  262.  
  263. #define    getpda()    ((pda_t *) PDAADDR)
  264. #define    private        (*((pda_t *) PDAADDR))
  265. #ifdef MP
  266. #define    cpuid()        ((cpuid_t)(private.p_cpuid))
  267. #else
  268. #define cpuid()        0
  269. #endif
  270. #define    cpumask()    (private.p_cpumask)
  271.  
  272. #ifdef MP
  273. #define ON_MP(X)    if (maxcpus > 1) {X;}
  274. #define IS_MP        (maxcpus > 1)
  275. #else
  276. #define ON_MP(X)
  277. #define IS_MP        0
  278. #endif
  279.  
  280. /*
  281.  * The following allows other cpus to do things for you 
  282.  */
  283. typedef void (*cpuacfunc_t)(void *, void *, void *, void *);
  284. typedef struct action_s {
  285.     cpuacfunc_t    dofunc;
  286.     void        *doarg0;
  287.     void        *doarg1;
  288.     void        *doarg2;
  289.     void        *doarg3;
  290.     struct action_s    *donext;
  291. } action_t;
  292.  
  293. extern void actioninit(void);
  294. extern void cpuaction(cpuid_t, cpuacfunc_t, int , ...);
  295. extern void doactions(void);
  296. extern void cpuvaction(register cpuid_t, register uint);
  297. extern void doacvec(void);
  298. extern void da_flush_tlb(void);
  299.  
  300. #define    A_NOW        0x0001    /* perform this action NOW */
  301. #define A_QUEUE        0x0002    /* perform this action later (at disp time) */
  302. #define    DOACTION    0xab    /* argument for sendintr() to do actions */
  303.  
  304. /* Opcodes for the cpu action vector */
  305. #if RTE
  306. #define VA_RTE_INTR        0x2
  307. #endif
  308. #define    VA_FORCE_RESCHED    0x4
  309. #define    VA_TRY_GANGSCHED    0x8
  310. #define    VA_LAST_OP        VA_TRY_GANGSCHED
  311.  
  312. /* Opcodes for the cpu delay action vector */
  313. #define    DA_ICACHE_FLUSH        0x1
  314. #define    DA_TLB_FLUSH        0x2
  315. #define    DA_LAST_OP        DA_TLB_FLUSH
  316.  
  317. /*
  318.  * Process tlb management
  319.  */
  320. #if JUMP_WAR
  321. /*
  322.  * Permit JUMP_WAR_SETS sets of wired entries for use by the jump
  323.  * workaround code.  Each set has up to NWIREDJUMP dual-tlb entries.
  324.  * We can accomodate any program that has 2*NWIREDJUMP-1 or fewer
  325.  * contiguous pages with End-Of-Page jump problems.  If there are 
  326.  * more than JUMP_WAR_SETS such sets of contiguous pages, performance
  327.  * will suffer.  Note that JUMP_WAR_SETS must be at least 2 to permit
  328.  * a program executing on an "bad" page to read a distant text page
  329.  * which is also bad.
  330.  */
  331.  
  332. #define jump_war_pte private.p_jump_war_pte
  333. #define jump_war_stats private.p_jump_war_stats
  334. #define jump_war_set_stats private.p_jump_war_set_stats
  335. #define jump_war_stolen private.p_jump_war_stolen
  336. #define jump_war_set private.p_jump_war_set
  337. #define max_jump_war_wired private.p_max_jump_war_wired
  338. #endif /* JUMP_WAR */
  339.  
  340. extern lock_t    tlbflushlock;    /* mp tlb flush lock */
  341. extern unsigned char    *tlbpids;    /* array of NPROC * MAXCPU tlbpids */
  342.                 /* these are the array of tlbpids in use */
  343.                 /* by each process on different processors */
  344.                 /* can't be 2-dimensional array since    */
  345.                 /* NPROC and MAXCPU are both tuneable    */
  346.  
  347. #define tlbpid(p)        (*((p)->p_tlbpid + cpuid()))
  348. extern void check_delay_tlbflush(int);
  349. extern void check_delay_iflush(void);
  350.  
  351. struct proc;
  352. extern void    utlbmiss_resume(struct proc *);
  353. extern void    wirepda(pda_t *);
  354. extern inst_t    *get_except_norm(void);
  355.  
  356. /*
  357.  * tlbsync() flags
  358.  */
  359. #define TLB_NOSLEEP        0x01
  360. #define STEAL_PHYSMEM        0x02
  361. #define NO_VADDR        0x04
  362. #define SPROC_TLBSYNC        0x08
  363. #define IMMEDIATE_BROADCAST    0x10
  364. #define ISOLATED_ONLY        0x20
  365. #define SPROC_TLBFORCE        0x40    /* force *all* cpus, including */
  366.                     /* isolated to sync tlbs       */
  367.  
  368. /* 
  369.  * process that is must run on isolated processor will not be paged out, nor
  370.  * killed by sched()
  371.  */
  372. #ifdef MP
  373. #define is_isolated(p)    (p->p_flag2 & SISOLATE)
  374. #else
  375. #define is_isolated(p)    (0)
  376. #endif
  377. #define    isomask(p)    ((((p)->p_shaddr) && ((p)->p_shmask & PR_SADDR)) ? \
  378.                 (p)->p_shaddr->s_isomask : (cpumask_t)0)
  379.  
  380. /* flags for check_delay_tlbflush() */
  381. #define ENTRANCE    0
  382. #define EXIT    1
  383.  
  384. #ifdef MP
  385. #define CHECK_DELAY_TLBFLUSH(flag)    {\
  386.     if (private.p_flags & PDAF_ISOLATED) \
  387.         check_delay_tlbflush(flag); \
  388.     }
  389.  
  390. #define CHECK_DELAY_IFLUSH()    {\
  391.     if (private.p_flags & PDAF_ISOLATED) \
  392.         check_delay_iflush(); \
  393.     }
  394. #else
  395. #define CHECK_DELAY_TLBFLUSH(x)
  396. #define CHECK_DELAY_IFLUSH()
  397. #endif
  398.  
  399. #endif /* _KERNEL */
  400.  
  401. #endif /* __SYS_PDA_H__ */
  402.